package dapps.entity.monitor;

import java.io.Serializable;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "indicator")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Indicator implements Serializable {

	private static final long serialVersionUID = 4865089954888777774L;

	private Empk pk;
	private Double value1;
	private Double value2;
	private Double value3;

	public Indicator(){		
	}
	
	
	public Indicator(Element element, Double value1, Double value2, Double value3) {				
		this.setElement(element);
		this.value1 = value1;
		this.value2 = value2;
		this.value3 = value3;
	}


	public Indicator(Empk pk){		
		this.pk = pk;
	}
	
	public void setElement(Element element) {
		Empk pknew = new Empk();
		pknew.setElement(element);
		this.pk = pknew;
	}
	
	@EmbeddedId
	public Empk getPk() {
		return pk;
	}
	public void setPk(Empk pk) {
		this.pk = pk;
	}

	public void setValue1(Double value1) {
		this.value1 = value1;
	}

	public void setValue2(Double value2) {
		this.value2 = value2;
	}
	public void setValue3(Double value3) {
		this.value3 = value3;
	}

	public Double getValue1() {
		return value1;
	}

	public Double getValue2() {
		return value2;
	}

	public Double getValue3() {
		return value3;
	}
	
	@Transient
	public String getValue1str() {
		if (value1 != null) {
			if (pk.getElement().getNumbertype() == 0)
				return String.valueOf(value1.intValue());
			else
				return String.valueOf(value1);
		} else {
			return "";
		}

	}

	@Transient
	public String getValue2str() {
		if (value2 != null) {
			if (pk.getElement().getNumbertype() == 0)
				return String.valueOf(value2.intValue());
			else
				return String.valueOf(value2);
		} else {
			return "";
		}
	}

	@Transient
	public String getValue3str() {
		if (value3 != null) {
			if (pk.getElement().getNumbertype() == 0)
				return String.valueOf(value3.intValue());
			else
				return String.valueOf(value3);
		} else {
			return "";
		}
	}

	

}